import redis
from flask import Flask
from flask_script import Manager
from flask_session import Session

from app.models import db
from app.views import blue


app = Flask(__name__)

app.config['SECRET_KEY']='123456'
# 设置flask-session的内容，将session数据保存在redis中
app.config['SESSION_TYPE'] = 'redis'
# redis.Redis(host='127.0.0.1', port=6379, password='密码')
app.config['SESSION_REDIS'] = redis.Redis(host='39.108.212.133', port=6379,password='123456')
# 初始化Session的两种方式:
# 第一种方式
Session(app)


#配置数据库
app.config['SQLALCHEMY_DATABASE_URI']='mysql+pymysql://root:123456@39.108.212.133:3306/blog'
db.init_app(app)
app.register_blueprint(blueprint=blue,url_prefix='/blog/')

if __name__ == '__main__':
    manage = Manager(app)
    manage.run()